import 'package:flutter/material.dart';

class DrawerBodyItem extends StatefulWidget {
  final IconData icon;
  final String title;
  final BorderRadiusGeometry borderRadius;
  const DrawerBodyItem({Key key, this.icon, this.title, this.borderRadius}) : super(key: key);

  @override
  _DrawerBodyItemState createState() =>
      _DrawerBodyItemState(this.icon, this.title,this.borderRadius);
}

class _DrawerBodyItemState extends State<DrawerBodyItem> {
  final IconData icon;
  final String title;
  final BorderRadiusGeometry borderRadius;
  Color _bgColor = Colors.white;
  _DrawerBodyItemState(this.icon, this.title, this.borderRadius);

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      child: Stack(
        children: <Widget>[
          Align(
              child: Container(
                height: 50,
                decoration: BoxDecoration(
                  color: _bgColor,
                  borderRadius: borderRadius
                ),
                child: Padding(
                  padding: EdgeInsets.fromLTRB(20, 0, 0, 0),
                  child: Row(
                    children: <Widget>[
                      Icon(
                        icon,
                        color: Colors.black54,
                      ),
                      Padding(
                        padding: EdgeInsets.fromLTRB(30, 0, 0, 0),
                        child: Text(
                          title,
                          style: TextStyle(fontSize: 17, color: Colors.black87),
                        ),
                      )
                    ],
                  ),
                ),
              ),
              alignment: Alignment.center),
        ],
      ),
      onTapDown: (down) {
        setState(() {
          _bgColor = Colors.black12;
        });
      },
      onTapUp: (up){
        setState(() {
          _bgColor = Colors.white;
        });
      },
    );
  }
}